package com.yunhai.xc.role.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yunhai.xc.role.domain.UserRole;
import com.yunhai.xc.role.persistence.RoleMapper;
import com.yunhai.xc.role.persistence.UserRoleMapper;

@Service
public class UserRoleService {
	@Autowired
	private UserRoleMapper userRoleMapper;

	@Autowired
	private RoleMapper roleMapper;

	public List<UserRole> getRoles(Integer uid) {
		List<Integer> roleId = roleMapper.getRoleId(uid);
		List<UserRole> list = new ArrayList<>();
		for (Integer role : roleId) {
			UserRole userRole = userRoleMapper.selectByRid(role);
			list.add(userRole);
		}
		return list;
	}
}
